package com.ATMgui;

import com.lovo.util.Util;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Login extends JPanel implements ActionListener {
    private Icon loginImg = Util.getIcon("/image/buttonLand.jpg");
    private Icon registerImg = Util.getIcon("/image/buttonLogin.jpg");
    private ATM frame;
    private JButton loginBtn = new JButton();

    public Login(ATM frame) {
        this.frame = frame;
        this.setLayout(null);

        JLabel textlabel1 = new JLabel("用户名：");
        textlabel1.setBounds(200, 150, 50, 30);
        this.add(textlabel1);
        //单行输入框
        JTextField textField1 = new JTextField();
        textField1.setBounds(250, 150, 250, 30);
        this.add(textField1);

        JLabel textlabel2 = new JLabel("密码：");
        textlabel2.setBounds(200, 200, 50, 30);
        this.add(textlabel2);
        //单行输入框
        JTextField textField2 = new JTextField();
        textField2.setBounds(250, 200, 250, 30);
        this.add(textField2);

        this.setOpaque(false);
        loginBtn = new JButton(loginImg);
        loginBtn.setBounds(200, 320, 100, 20);
        this.add(loginBtn);
        loginBtn.addActionListener(this);

        this.setOpaque(false);
        JButton registerBtn = new JButton(registerImg);
        registerBtn.setBounds(400, 320, 100, 20);
        this.add(registerBtn);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == loginBtn) {
            frame.switchPanel("菜单");
        }
    }
}
